<?php
declare (strict_types=1);

namespace app;

/**
 * 基础公用服务层
 */
class BaseService
{

    /**
     * 枚举排队状态
     * @var array|string[]
     */
    public static array $EnumQueueStatus = [
        1 => '排队中', 2 => '出袋中', 3 => '出袋成功', 4 => '出袋失败',
    ];

    /**
     * 生成地理位置缓存key
     * @param int $userId
     * @return string
     */
    public static function generateLocationKey(int $userId): string
    {
        return 'UserIdLocation:' . $userId;
    }

    /**
     * 生成出袋排队缓存key
     * @param string $mac_id
     * @return string
     */
    public static function generateScanBagQueueKey(string $mac_id): string
    {
        return 'ScanBagQueue:' . $mac_id;
    }

    /**
     * 生成出袋策略缓存key
     * @param int $key
     * @return string
     */
    public static function generateScanBagStrategyKey(int $key): string
    {
        return 'ScanBagStrategy:' . $key;
    }

    /**
     * 生成出袋程序缓存key
     * @param string $imei
     * @return string
     */
    public static function generateBagOutProgramKey(string $imei): string
    {
        return 'BagOutProgram:' . $imei;
    }

    /**
     * 获取取袋安全码key规则
     * @param int $user_id
     * @param string $way
     * @param string $mac_id
     * @return string
     */
    public static function generateBagOutSafeCodeKey(int $user_id, string $way, string $mac_id): string
    {
        //定义缓存key
        return 'SafeCode:' . $way . ':' . $mac_id . '_' . $user_id;
    }

    /**
     * 获取取袋码key规则
     * @param int $user_id
     * @param string $way
     * @param string $mac_id
     * @return string
     */
    public static function generateBagOutWaycodeKey(int $user_id, string $way, string $mac_id): string
    {
        //定义缓存key
        $key = 'Waycode:' . $way . ':' . $mac_id . '_' . $user_id . uniqid();
        return md5($key);
    }

    public static function generateTaskCodeKey(int $user_id, int $task_id,string $content): string
    {
        //定义缓存key
        $key = 'Taskcode:' . $task_id . ':' . $user_id.":".$content;
        return md5($key);
    }


}
